/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.se2.meteocal.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Ugo
 */
@Entity
@NamedQueries({
    @NamedQuery(name = ParticipationNotification.findByParticipation, query = "SELECT p FROM ParticipationNotification p WHERE p.participation=:participation"),
    @NamedQuery(name = ParticipationNotification.findByParticipationAndType, query = "SELECT p FROM ParticipationNotification p WHERE p.participation=:participation AND p.type=:type"),
    @NamedQuery(name = ParticipationNotification.findByUserNotSeen, query = "SELECT p FROM ParticipationNotification p WHERE p.participation.user=:user AND p.seen=FALSE"),
    @NamedQuery(name = ParticipationNotification.findByUser, query = "SELECT p FROM ParticipationNotification p WHERE p.participation.user=:user AND p.type=:type"),
   

})
@Table(name = "participationnotification")
public class ParticipationNotification implements Serializable {
    private static final long serialVersionUID = 1L;
    public static final String findByParticipation = "ParticipationNotification.findByParticipation";
    public static final String findByParticipationAndType = "ParticipationNotification.findByParticipationAndType";

    public static final String findByUserNotSeen = "ParticipationNotification.findByUserNotSeen";
    public static final String findByUser = "ParticipationNotification.findByUser";

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id1;

   @OneToOne
   private Participation participation;
   
   @Column(name ="TYPE")
   private Long type;
    
   @Column(name = "SEEN")
   @NotNull(message = "May not be empty")
   private Boolean seen;
   
   public ParticipationNotification(){
       
   }
   
   public ParticipationNotification(Participation participation){
       this.participation=participation;
   }
   
   public void setId1(Long id){
       this.id1=id;
   }
   
   public Long getId1(){
       return this.id1;
   }
   
   public void setParticipation(Participation participation){
       this.participation=participation;
       this.seen=false;
      
   }
   
   public Participation getParticipation(){
       return this.participation;
   }
   
   public void setType(Long type){
       this.type=type;
   }
   
   public Long getType(){
       return this.type;
   }
   
   public void setSeen(Boolean seen){
       this.seen=seen;
   }
   
   public Boolean isSeen(){
       return this.seen;
   }
   
}
